﻿using KineBall.GameLogic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace KineBall.Rendering
{
    public class BallModel
    {
        private Matrix TranslationToOrigin = Matrix.CreateTranslation(new Vector3(-0.8648543f, -1.012608f, 0.1980919f));

        public Matrix Scale { get; set; }
        public Model Model { get; set; }

        public BallModel(Model model, float scale)
        {
            Model = model;
            Scale = Matrix.CreateScale(scale);
        }

        public void DrawBall(Camera camera, Ball ball)
        {
            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (BasicEffect e in mesh.Effects)
                {
                    e.World = TranslationToOrigin * Scale * Matrix.CreateTranslation(ball.Position);
                    e.Projection = camera.Projection;
                    e.View = camera.View;

                    e.EnableDefaultLighting();
                }

                mesh.Draw();
            }
        }


    }
}
